﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DataAccess;

namespace EntityDaoLibrary
{
    public class OperatorDAO: IEntityDAO
    {
        private IDataAccess data;
        public OperatorDAO()
        { 
        }

        public OperatorDAO(IDataAccess data)
        {
            this.data = data;
        }
    
        #region IEntityDAO 成员

        public void  insertEntity(System.Data.DataSet entityData)
        {
 	        throw new NotImplementedException();
        }

        public void  deleteEntity(System.Data.DataSet entityData)
        {
 	        throw new NotImplementedException();
        }

        public void  updateEntity(System.Data.DataSet entityData)
        {
 	        throw new NotImplementedException();
        }

        public System.Data.DataSet  FindByPrimaryKey(object strKeyValue)
        {
 	        throw new NotImplementedException();
        }

        #endregion

        public int FindByOperatorID(string operatorID,string pwd)
        {
            try
            {
                SqlStruct sqlStruct = new SqlStruct();
                string sql = "";
                QueryParameterCollection para;
                DataSet ds = new DataSet();
                sql = "select * from czryk where id=@id and passwd=@pwd";
                para = new QueryParameterCollection(2);
                para.Add("@id", operatorID);
                para.Add("@pwd", pwd);
                data.ExecuteDataset(sql, para, ds);
                if (ds.Tables[0].Rows.Count>0)
                {
                    return 0;
                }
                return 1;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
}
}
